package encrypting;

/**
 * This class implements a system for encrypt words.
 * @author Alexandre, Cristovao, Raul, Rodolpho, Tales
 * @version 1.1
 * @milestone Number 2
 */
public class EncryptSystem {
	
	private Encryptable encryptType;
	
	private static EncryptSystem encryptSystem = null;
	
	/**
	 * Constructor of the class.
	 * @param encryptType - a type of encrypting
	 */
	protected EncryptSystem(Encryptable encryptType) {
		this.encryptType = encryptType;
	}
	
	/**
	 * get the instance of the encrypt system.
	 * @return
	 */
	public static synchronized EncryptSystem getInstance(){
		if (encryptSystem == null){
			encryptSystem = new EncryptSystem(new SHA1Encrypt());
		}
		return encryptSystem;
	}
	
	/**
	 * Changes the encrypting type of the system.
	 * @param encryptType - new type of encrypting that will be used in the ImHere System.
	 */
	public void setEncryptTye(Encryptable encryptType) {
		this.encryptType = encryptType;
	}

	/**
	 * Encrypts a word.
	 * @param word the word that will be encrypted
	 * @return the encrypted word.
	 */
	public String encryptWord(String word){
		return this.encryptType.encryptWord(word);
	}

}
